package com.streamkar.entity.request;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.streamkar.entity.base.IdRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName UpdateIncentiveRequest
 * @Description
 * @Author tyfrost
 * @Date 2018/12/5 5:36 PM
 * @Version 1.0
 */
public class UpdateIncentiveRequest extends IdRequest {

    /**
     * 所属国家
     */
    private JSONArray country;
    /**
     * 开始时间
     */
    private String startDate;
    /**
     * 结束时间
     */
    private String endDate;
    /**
     * Incentive 描述
     */
    private String keyWord;
    /**
     * Incentive 图片
     */
    private String coverImg;

    /**
     * 状态 0：正常 1：删除
     */
    private Integer status;

    /**
     * 是否生效 0：未生效 1：生效
     */
    private Integer activate;

    private JSONObject jsonObject = new JSONObject();

    public JSONObject toEvent(Integer userId) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        jsonObject.put("updateUserId", userId);
        jsonObject.put("updateDate", sdf.format(new Date()));
        return jsonObject;
    }

    public JSONArray getCountry() {
        return country;
    }

    public void setCountry(JSONArray country) {
        this.country = country;
        if (!CollectionUtils.isEmpty(country)) {
            jsonObject.put("country", country);
        }
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String startDate) {
        this.startDate = startDate;
        if (StringUtils.isNotBlank(startDate)) {
            jsonObject.put("startDate", startDate);
        }
    }

    public String getEndDate() {
        return endDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
        if (StringUtils.isNotBlank(endDate)) {
            jsonObject.put("endDate", endDate);
        }
    }

    public String getKeyWord() {
        return keyWord;
    }

    public void setKeyWord(String keyWord) {
        this.keyWord = keyWord;
        if (StringUtils.isNotBlank(keyWord)) {
            jsonObject.put("keyWord", keyWord);
        }
    }

    public String getCoverImg() {
        return coverImg;
    }

    public void setCoverImg(String coverImg) {
        this.coverImg = coverImg;
        if (StringUtils.isNotBlank(coverImg)) {
            jsonObject.put("coverImg", coverImg);
        }
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
        if (null != status) {
            jsonObject.put("status", status);
        }
    }

    public Integer getActivate() {
        return activate;
    }

    public void setActivate(Integer activate) {
        this.activate = activate;
        if (null != status) {
            jsonObject.put("activate", activate);
        }
    }

    public JSONObject getJsonObject() {
        return jsonObject;
    }

    public void setJsonObject(JSONObject jsonObject) {
        this.jsonObject = jsonObject;
    }
}
